angular.module('starter.controllers',[])
    .controller('HomeCtrl',function ($scope,$timeout,$rootScope) {
        $scope.title = '首页';
        $scope.bannerList = [
            {
                img:'./images/banner.jpg'
            },
            {
                img:'./images/banner.jpg'
            },
            {
                img:'./images/banner.jpg'
            },
            {
                img:'./images/banner.jpg'
            }
        ];
        $scope.activity = [
            {
                name:'健康',
                imgSrc:"./images/health-img.png",
                tips:"yellow-tip"
            },
            {
                name:'品质',
                imgSrc:"./images/quality-img.png",
                tips:"blue-tip"
            },
            {
                name:'父母情',
                imgSrc:"./images/kindness-img.png",
                tips:"red-tip"
            },
            {
                name:'新鲜',
                imgSrc:"./images/fresh-img.png",
                tips:"green-tip"
            },
            {
                name:'新鲜',
                imgSrc:"./images/fresh-img.png",
                tips:"green-tip"
            }
        ]
        $scope.autoSlide=function() {
            new Swiper('#swiper-container', {
                slidesPerView : 'auto',
                freeMode:true,
                spaceBetween:5,
                observer: true,//修改swiper自己或子元素时，自动初始化swiper
                observeParents: true,//修改swiper的父元素时，自动初始化swiper
                autoHeight:true
            })
        }

        $scope.medicalCare = true;
        $scope.intelligent = false;
        $scope.health = false;
        $scope.colligate = true;
        $scope.salesVolume = false;
        $scope.evaluation = false;
        $scope.distance = false;
        $scope.changeGoods = function (type) {
            if(type=='medicalCare'){
                $scope.medicalCare = true;
                $scope.intelligent = false;
                $scope.health = false;
            }else if(type=='intelligent'){
                $scope.medicalCare = false;
                $scope.intelligent = true;
                $scope.health = false;
            }else if(type=='health'){
                $scope.medicalCare = false;
                $scope.intelligent = false;
                $scope.health = true;
            }
        }
        $scope.changeGoodsState = function (type) {
            if(type=='colligate'){
                $scope.colligate = true;
                $scope.salesVolume = false;
                $scope.evaluation = false;
                $scope.distance = false;
            }else if(type=='salesVolume'){
                $scope.colligate = false;
                $scope.salesVolume = true;
                $scope.evaluation = false;
                $scope.distance = false;
            }else if(type=='evaluation'){
                $scope.colligate = false;
                $scope.salesVolume = false;
                $scope.evaluation = true;
                $scope.distance = false;
            }else if(type=='distance'){
                $scope.colligate = false;
                $scope.salesVolume = false;
                $scope.evaluation = false;
                $scope.distance = true;
            }
        }


    })
    .controller('DiscoveryCtrl',function ($scope,$rootScope) {
        $scope.title = '发现';

        $scope.colligate = true;
        $scope.pension = false;
        $scope.preserveHealth = false;
        $scope.tourism = false;
        $scope.intelligent = false;
        $scope.colligatearr = [
            {
                ID:'000001',
                title:'综合每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
                subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
                movieImg:'',
                movieTime:'',
                images:[
                    './images/find-img1.png',
                    './images/find-img1.png',
                    './images/find-img1.png'
                ],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                ID:'000001',
                title:'综合每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
                subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
                movieImg:'',
                movieTime:'',
                images:[
                    './images/find-img1.png',
                    './images/find-img1.png',
                    './images/find-img1.png'
                ],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                title:'每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
                subtitle:"",
                movieImg:'./images/find-movie.png',
                movieTime:'02:08',
                images:[],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                title:'“潮起来”!“旅居养老”渐成中国老年人生活新风尚',
                subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
                movieImg:'',
                movieTime:'',
                images:[
                    './images/find-img1.png'
                ],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                title:'每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
                subtitle:"",
                movieImg:'./images/find-movie.png',
                movieTime:'02:08',
                images:[],
                praiseNum:'2859',
                shareNum:'191'
            },,
            {
                title:'每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
                subtitle:"",
                movieImg:'./images/find-movie.png',
                movieTime:'02:08',
                images:[],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                title:'“潮起来”!“旅居养老”渐成中国老年人生活新风尚',
                subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
                movieImg:'',
                movieTime:'',
                images:[
                    './images/find-img1.png'
                ],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                title:'“潮起来”!“旅居养老”渐成中国老年人生活新风尚',
                subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
                movieImg:'',
                movieTime:'',
                images:[
                    './images/find-img1.png'
                ],
                praiseNum:'2859',
                shareNum:'191'
            }
        ];
        $scope.pensionarr = [
            {
            title:'养老每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
            subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
            movieImg:'',
            movieTime:'',
            images:[
                './images/find-img1.png',
                './images/find-img1.png',
                './images/find-img1.png'
            ],
            praiseNum:'2859',
            praised:true,
            shareNum:'191'
        },
            {
                title:'每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
                subtitle:"",
                movieImg:'./images/find-movie.png',
                movieTime:'02:08',
                images:[],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                title:'“潮起来”!“旅居养老”渐成中国老年人生活新风尚',
                subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
                movieImg:'',
                movieTime:'',
                images:[
                    './images/find-img1.png'
                ],
                praiseNum:'2859',
                shareNum:'191'
            }];
        $scope.preserveHealtharr = [
            {
            title:'养生每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
            subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
            movieImg:'',
            movieTime:'',
            images:[
                './images/find-img1.png',
                './images/find-img1.png',
                './images/find-img1.png'
            ],
            praiseNum:'2859',
            shareNum:'191'
        },
            {
                title:'每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
                subtitle:"",
                movieImg:'./images/find-movie.png',
                movieTime:'02:08',
                images:[],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                title:'“潮起来”!“旅居养老”渐成中国老年人生活新风尚',
                subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
                movieImg:'',
                movieTime:'',
                images:[
                    './images/find-img1.png'
                ],
                praiseNum:'2859',
                shareNum:'191'
            }];
        $scope.tourismarr = [
            {
            title:'旅游每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
            subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
            movieImg:'',
            movieTime:'',
            images:[
                './images/find-img1.png',
                './images/find-img1.png',
                './images/find-img1.png'
            ],
            praiseNum:'2859',
            shareNum:'191'
        },
            {
                title:'每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
                subtitle:"",
                movieImg:'./images/find-movie.png',
                movieTime:'02:08',
                images:[],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                title:'“潮起来”!“旅居养老”渐成中国老年人生活新风尚',
                subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
                movieImg:'',
                movieTime:'',
                images:[
                    './images/find-img1.png'
                ],
                praiseNum:'2859',
                shareNum:'191'
            }];
        $scope.intelligentarr = [
            {
            title:'智能每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
            subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
            movieImg:'',
            movieTime:'',
            images:[
                './images/find-img1.png',
                './images/find-img1.png',
                './images/find-img1.png'
            ],
            praiseNum:'2859',
            shareNum:'191'
        },
            {
                title:'每天吃一瓣大蒜，你能收到4个益处！快转给家里人',
                subtitle:"",
                movieImg:'./images/find-movie.png',
                movieTime:'02:08',
                images:[],
                praiseNum:'2859',
                shareNum:'191'
            },
            {
                title:'“潮起来”!“旅居养老”渐成中国老年人生活新风尚',
                subtitle:"随着中国居民经济水平的不断增高，“旅居养老”正成为不少中国老年人的生活新潮流...",
                movieImg:'',
                movieTime:'',
                images:[
                    './images/find-img1.png'
                ],
                praiseNum:'2859',
                shareNum:'191'
            }];
        $scope.toDetail = function(id){
            window.location.href="#/tab/discovery/"+id
            // console.log(id)
        }
        $scope.changeTabs = function (type) {
            if(type=='colligate'){
                $scope.colligate = true;
                $scope.pension = false;
                $scope.preserveHealth = false;
                $scope.tourism = false;
                $scope.intelligent = false;
            }else if(type=='pension'){
                $scope.colligate =false ;
                $scope.pension = true;
                $scope.preserveHealth = false;
                $scope.tourism = false;
                $scope.intelligent = false;
            }else if(type=='preserveHealth'){
                $scope.colligate = false;
                $scope.pension = false;
                $scope.preserveHealth = true;
                $scope.tourism = false;
                $scope.intelligent = false;
            }else if(type=='tourism'){
                $scope.colligate = false;
                $scope.pension = false;
                $scope.preserveHealth = false;
                $scope.tourism = true;
                $scope.intelligent = false;
            }else if(type=='intelligent'){
                $scope.colligate = false;
                $scope.pension = false;
                $scope.preserveHealth = false;
                $scope.tourism = false;
                $scope.intelligent = true;
            }

        }
    })
    .controller('FindDetailCtrl',function ($scope,$rootScope) {
        $rootScope.title = '发现';
        $rootScope.others = [
            {
                'iconSrc':'./images/share-icon.png',
                iconTap:function () {
                    //        do something
                }
            }
        ];
    })
    .controller('OrderCtrl',function ($scope,$rootScope) {
        $scope.title = '订单'
    })
    .controller('AboutCtrl',function ($scope,$rootScope) {
        $scope.title = '我的';

        $scope.toMassage = function () {
            window.location.href = '#/tab/massage'
        }
    })
    .controller('MassageCtrl',function ($scope,$rootScope) {
        $rootScope.title = '消息盒子';
        //大于100显示99+
    })
    .controller('SetCtrl',function ($scope,$rootScope) {
        $rootScope.title = '设置';
    })
    .controller('MsgTipCtrl',function ($scope,$rootScope) {
        $rootScope.title = '消息设置';
    })
    .controller('LatelyLoginCtrl',function ($scope,$rootScope) {
        $rootScope.title = '最近登录记录';
    })
    .controller('QandACtrl',function ($scope,$rootScope) {
        $rootScope.title = '账号相关答疑';
    })
    .controller('MyAccountCtrl',function ($scope,$rootScope) {
        $rootScope.title = '我的账号';
    })
    .controller('ChangePasswordCtrl',function ($scope,$rootScope) {
        $rootScope.title = '设置密码';
    })
    .controller('RegisterNameCtrl',function ($scope,$rootScope,$stateParams) {
        var title = '注册';
        if($stateParams.titleName=='changeName'){
            title = '修改用户名';
        }
        $rootScope.title = title;
        $rootScope.others = [
            {
                'text':'保存',
                iconTap:function () {
                    //        do something
                }
            }
        ];
    })
    .filter("toCn", function () {
        return function (input) {
            var output= '';
            if(input=='zh'){
                output = '综合';
            }else if(input=='sf'){
                output = '顺丰';
            }else if(input=='tc'){
                output = '同城';
            }
            return output;
        }
    });